home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Graphics Programming (2nd Edition) / Visual Basic Graphics Programming 2nd Edition.iso / OldSrc / CH12 / SRC / LIGHT3.BAS < prev    next >
Encoding:
BASIC Source File  |  1997-01-08  |  4.1 KB  |  75 lines

  1. Attribute VB_Name = "Light"
  2. Option Explicit
  3.  
  4. ' Location of light source.
  5. Global Const LightX = 100
  6. Global Const LightY = 500
  7. Global Const LightZ = 1000
  8. Global Const LightIa = 128
  9. Global LightIi As Single
  10.  
  11. ' Constants for the surfaces.
  12. Global LightKd As Single
  13. Global LightKa As Single
  14. Global LightKdist As Single
  15.  
  16. Type PALETTEENTRY
  17.     peRed As Byte
  18.     peGreen As Byte
  19.     peBlue As Byte
  20.     peFlags As Byte
  21. End Type
  22. Public Const PC_EXPLICIT = &H2      ' Match to system palette index.
  23. Public Const PC_NOCOLLAPSE = &H4    ' Do not match color existing entries.
  24.  
  25. ' GetDeviceCaps constants.
  26. Global Const RASTERCAPS = 38    ' Raster device capabilities.
  27. Global Const RC_PALETTE = &H100 ' Has palettes.
  28. Global Const NUMRESERVED = 106  ' # reserved entries in palette.
  29. Global Const SIZEPALETTE = 104  ' Size of system palette.
  30.  
  31. #If Win32 Then  ' 32-bit VB.
  32.     Type BITMAP ' 24 bytes
  33.         bmType As Long
  34.         bmWidth As Long
  35.         bmHeight As Long
  36.         bmWidthBytes As Long
  37.         bmPlanes As Integer
  38.         bmBitsPixel As Integer
  39.         bmBits As Long
  40.     End Type
  41.     Global Const BITMAP_SIZE = 24
  42.     Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Integer, ByVal nIndex As Integer) As Integer
  43.     Declare Function ResizePalette Lib "gdi32" (ByVal hPalette As Integer, ByVal nNumEntries As Integer) As Integer
  44.     Declare Function SetPaletteEntries Lib "gdi32" (ByVal hPalette As Integer, ByVal wStartIndex As Integer, ByVal wNumEntries As Integer, lpPaletteEntries As PALETTEENTRY) As Integer
  45.     Declare Function GetPaletteEntries Lib "gdi32" (ByVal hPalette As Integer, ByVal wStartIndex As Integer, ByVal wNumEntries As Integer, lpPaletteEntries As PALETTEENTRY) As Integer
  46.     Declare Function GetSystemPaletteEntries Lib "gdi32" (ByVal hdc As Integer, ByVal wStartIndex As Integer, ByVal wNumEntries As Integer, lpPaletteEntries As PALETTEENTRY) As Integer
  47.     Declare Function RealizePalette Lib "gdi32" (ByVal hdc As Long) As Long
  48.     Declare Function GetBitmapBits Lib "gdi32" (ByVal hBitmap As Integer, ByVal dwCount As Long, lpBits As Any) As Long
  49.     Declare Function SetBitmapBits Lib "gdi32" (ByVal hBitmap As Integer, ByVal dwCount As Long, lpBits As Any) As Long
  50.     Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
  51.     Declare Function GetNearestPaletteIndex Lib "gdi32" (ByVal hPalette As Integer, ByVal crColor As Long) As Integer
  52. #Else           ' 16-bit VB.
  53.     Type BITMAP ' 14 bytes
  54.         bmType As Integer
  55.         bmWidth As Integer
  56.         bmHeight As Integer
  57.         bmWidthBytes As Integer
  58.         bmPlanes As String * 1
  59.         bmBitsPixel As String * 1
  60.         bmBits As Long
  61.     End Type
  62.     Global Const BITMAP_SIZE = 14
  63.     Declare Function GetDeviceCaps Lib "GDI" (ByVal hdc As Integer, ByVal nIndex As Integer) As Integer
  64.     Declare Function ResizePalette Lib "GDI" (ByVal hPalette As Integer, ByVal nNumEntries As Integer) As Integer
  65.     Declare Function SetPaletteEntries Lib "GDI" (ByVal hPalette As Integer, ByVal wStartIndex As Integer, ByVal wNumEntries As Integer, lpPaletteEntries As PALETTEENTRY) As Integer
  66.     Declare Function GetPaletteEntries Lib "GDI" (ByVal hPalette As Integer, ByVal wStartIndex As Integer, ByVal wNumEntries As Integer, lpPaletteEntries As PALETTEENTRY) As Integer
  67.     Declare Function GetSystemPaletteEntries Lib "GDI" (ByVal hdc As Integer, ByVal wStartIndex As Integer, ByVal wNumEntries As Integer, lpPaletteEntries As PALETTEENTRY) As Integer
  68.     Declare Function RealizePalette Lib "User" (ByVal hdc As Integer) As Integer
  69.     Declare Function GetBitmapBits Lib "GDI" (ByVal hBitmap As Integer, ByVal dwCount As Long, lpBits As Any) As Long
  70.     Declare Function SetBitmapBits Lib "GDI" (ByVal hBitmap As Integer, ByVal dwCount As Long, lpBits As Any) As Long
  71.     Declare Function GetObject Lib "GDI" (ByVal hObject As Integer, ByVal nCount As Integer, lpObject As Any) As Integer
  72.     Declare Function GetNearestPaletteIndex Lib "GDI" (ByVal hPalette As Integer, ByVal crColor As Long) As Integer
  73. #End If
  74.  
  75.